package com.wisely.highlight_spring4.ch2.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;


/**
 * @ClassName DemoPublisher
 * @Package com.wisely.highlight_spring.ch2.event
 * @Description TODO
 * @Author zjb
 * @Date 2018/7/20 14:29
 * @Version 1.0
 **/
@Component
public class DemoPublisher {
    @Autowired
    //注入ApplicationContext用来发布事件
    ApplicationContext applicationContext;

    public void  publish(String msg){
        //使用ApplicationContext的publishEvent方法来发布
        applicationContext.publishEvent(new DemoEvent(this,msg));
    }
}
